package binary_IO;

import java.io.*;

public class TestObjectOutputStream {
	public static void main(String[] args) throws IOException, ClassNotFoundException {
		// Create an output stream for file object.dat
		ObjectOutputStream output = 
			new ObjectOutputStream(new FileOutputStream("object.dat"));
		
		// Write a string, double value, and object to the file
		output.writeUTF("John");
		output.writeDouble(85.5);
		output.writeObject(new java.util.Date());

		// Close output stream
		output.close();
		ObjectInputStream input =
			new ObjectInputStream(new FileInputStream("object.dat"));
		while (!(input.available() == 0)) 
		{
			System.out.println(input.readUTF() + " " + input.readDouble() + " " + input.readObject());
		}
	}
}



